# -*- coding: utf-8 -*-
"""
Created on Tue Apr 30 16:05:06 2024

@author: 29865
"""

import pandas as pd
import matplotlib.pyplot as plt
path = '一、车次上车人数统计表.xlsx'
data = pd.read_excel(path)
D02 = data.loc[data['车次'] == 'D02', ['日期', '上车人数']].sort_values('日期')
D03 = data.loc[data['车次'] == 'D03', ['日期', '上车人数']].sort_values('日期')

# 设置表格基础外观信息
plt.rcParams['font.sans-serif'] = 'SimHei'
plt.xlabel('日期')
plt.ylabel('上车人数')
plt.title('D02+D03车次上车人数折线图')

# 获取x轴和y轴的值，并绘制散点图
x = D02['日期'].astype(str)
y_d02 = D02['上车人数']
y_d03 = D03['上车人数']
plt.plot(x, y_d02, 'r*--')
plt.plot(x, y_d03, 'b*--')
x_ticks = ['20150101', '20150105', '20150110',
           '20150115', '20150120', '20150124']
plt.xticks(x_ticks, rotation=45)
